<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\validate;

/**
 * 验证器
 */
class Staff extends AdminBase
{
    
    // 验证规则
    protected $rule =   [
        'staff_name'  => 'require',
        'company_id'  => 'require',
        'branch_id'  => 'require',
        'phones'          => 'require|length:11|unique:staff',
        'card_id'          => 'require|unique:staff',
    ];
    
    // 验证提示
    protected $message  =   [
        
        'staff_name.require'    => '用户名不能为空',
        'company_id.require'    => '公司不能为空',
        'branch_id.require'    => '部门不能为空',
        'phones.require'    => '手机号不能为空',
        'phones.length'    => '手机号长度不正确',
        'phones.unique'    => '手机号已存在',
        'card_id.require'    => '身份证号不能为空',
        // 'card_id.length'    => '身份证号长度不正确',
        'card_id.unique'    => '身份证号长度不正确',
    ];

    // 应用场景
    protected $scene = [
        
        'add'   =>  ['staff_name','company_id','branch_id','phones','card_id'],
        'edit'  =>  ['staff_name','company_id','branch_id','phones','card_id'],
    ];
}
